package com.guagua.chat.post;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 北京八度互联科技有限公司版权所有
 * Copyright (C) Badu Corporation. All Rights Reserved
 * @author liyi
 * 房间主页-贴子数据库映射类 数据库表名t_posts_<房间ID末位>
 */

public class PostInfo implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private long id;//ID
	
	private long parent_id;//主ID
	
	private long user_id;//发布者ID
	
	private long room_id;//房间ID
	
	private String user_nick;//用户昵称
	
	private String title;//标题
	
	private String content;//内容
	
	private long op_time;//最后操作时间
	
	private long create_time;//发布时间
	
	private int pageView;//浏览数
	
	private String date;//发布日期
	
	private String time;//发布时间
	/**
	 * 根据需求显示（当天为10:15 其他为10-27 10月27日)
	 */
	private String revertTime;//回复时间
	
	private int comment_count;//评论数
	
	
	
	public String getRevertTime() {
		return revertTime;
	}

	public void setRevertTime(String revertTime) {
		this.revertTime = revertTime;
	}

	public long getRoom_id() {
		return room_id;
	}

	public void setRoom_id(long room_id) {
		this.room_id = room_id;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getParent_id() {
		return parent_id;
	}

	public void setParent_id(long parent_id) {
		this.parent_id = parent_id;
	}

	public long getUser_id() {
		return user_id;
	}

	public void setUser_id(long user_id) {
		this.user_id = user_id;
	}

	public String getUser_nick() {
		return user_nick;
	}

	public void setUser_nick(String user_nick) {
		this.user_nick = user_nick;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}


	public long getOp_time() {
		return op_time;
	}

	public void setOp_time(long op_time) {
		this.op_time = op_time;
	}
	
	
	
	public long getCreate_time() {
		return create_time;
	}

	public void setCreate_time(long create_time) {
		this.create_time = create_time;
		parseDate();//日期转换
		parseRevertDateTime();
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getPageView() {
		return pageView;
	}

	public void setPageView(int pageView) {
		this.pageView = pageView;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}
    
	public int getComment_count() {
		return comment_count;
	}

	public void setComment_count(int comment_count) {
		this.comment_count = comment_count;
	}

	/**
	 * 将long形日期装换
	 */
	private void parseDate(){
		Date date = new Date(this.create_time);
		SimpleDateFormat sFormat = new SimpleDateFormat("MM月dd日");
		this.setDate(sFormat.format(date));
		sFormat = new SimpleDateFormat("HH:mm");
		this.setTime(sFormat.format(date));
	}
	/**
	 * 格式化回复时间
	 */
	private void parseRevertDateTime(){
		Date date = new Date(System.currentTimeMillis());
		SimpleDateFormat sFormat = new SimpleDateFormat("yyyyMMdd");
		String t1 = sFormat.format(date);//当天日期
		date = new Date(this.create_time);
		String t2 = sFormat.format(date);//操作日期
		if(t1.equals(t2)){//当天
			sFormat = new SimpleDateFormat("HH:mm");
			this.revertTime = sFormat.format(new Date(this.create_time));
		}else{//非当天
			sFormat = new SimpleDateFormat("MM-dd");
			this.revertTime = sFormat.format(new Date(this.create_time));
		}
	}
	
	
}
